package com.sinog.biz.schedule;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.sinog.biz.BizApplication;
import com.sinog.biz.config.ThreadPoolConfig;
import com.sinog.biz.service.api.DataTransmissionService;
import com.sinog.biz.service.api.async.AsyncUploadFileToFtp;
import com.sinog.biz.service.business.PrisonerMainService;
import com.sinog.biz.service.business.SearchCodeListService;
import com.sinog.biz.service.business.SearchCodeService;
import com.sinog.biz.service.business.UploadAppendixFileFeignService;
import com.sinog.biz.service.business.VerificationService;
import com.sinog.biz.service.business.XxblService;
import com.sinog.biz.util.FileUtil;
import com.sinog.biz.util.FtpUtil;
import com.sinog.biz.util.GdFtpUtil;
import com.sinog.biz.util.IdGen;
import com.sinog.core.domain.PrisonerCjpg;
import com.sinog.core.domain.PrisonerFx;
import com.sinog.core.domain.PrisonerHc;
import com.sinog.core.domain.PrisonerMain;
import com.sinog.core.domain.PrisonerSr;
import com.sinog.core.domain.PrisonerZn;
import com.sinog.core.domain.PrisonersZyjn;
import com.sinog.core.domain.UserInterFaceEntity;
import com.sinog.core.model.MultimediaInfo;
import com.sinog.core.model.UploadAppendixFile;
import com.sinog.core.model.UserDTO;
import com.sinog.core.util.Hex;
import com.sinog.core.util.JsonUtil;
import com.sinog.core.utilbean.Constants;
import com.sinog.core.utilbean.MiddleSqlReturnCode;
import com.sinog.core.utilbean.Result;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPFile;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

/**
 * @author lk
 * @desc 中间库，广东，监狱oracle对接。基本信息与信息补录
 * @date 2022/11/30 16:29
 */

@Slf4j
@Component
@Configuration
@EnableAsync
@ConditionalOnProperty(name = "gkzx.azbj.outerInterface.db.gdOracle.open", havingValue = "true")
public class ShadowForOracleScheduleGd {

    @Autowired
    private ThreadPoolConfig threadPoolConfig;
    private static final Pattern PATTERN = Pattern.compile("\\d{9}");
    /**
     * 中间库数据源
     */
    private JdbcTemplate oracleJdbcTemplate;
    /**
     * 安置帮教库数据源
     */
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private DataTransmissionService dataTransmissionService;
    @Autowired
    private SearchCodeListService searchCodeListService;
    @Autowired
    private SearchCodeService searchCodeService;
    @Resource
    private StringRedisTemplate stringRedisTemplate;
    @Autowired
    private ThreadPoolTaskExecutor taskExecutor;
    @Autowired
    private VerificationService verificationService;
    @Autowired
    private AsyncUploadFileToFtp asyncUploadFileToFtp;
    @Resource
    private UploadAppendixFileFeignService uploadAppendixFileFeignService;
    @Autowired
    private XxblService xxblService;
    @Autowired
    private PrisonerMainService prisonerMainService;
    @Value("${gkzx.azbj.ftp.datapath}")
    private String datapath;
    @Autowired
    private GdFtpUtil gdFtpUtil;

    /**
     * 定时从中间库拉取数据保存到本地库(生产上每天晚11点跑：0 0 23 * * ?)，
     * 本地测试每分钟执行一次：0 0/1 * * * ?
     */
    @Async
    @Scheduled(cron = "${gkzx.azbj.outerInterface.db.gdOracle.cron}")
    public void predictWarningShadowTask() {
        log.info("\n>>>>>>>>>>>starting......从中间库同步预安置人员基本数据<<<<<<<<<<");
        SimpleDateFormat formatTime = new SimpleDateFormat("yyyy-MM-dd");
        ApplicationContext applicationContext = BizApplication.applicationContext;
        long startTime = System.currentTimeMillis();
        if (!ObjectUtils.allNotNull(oracleJdbcTemplate)) {
            oracleJdbcTemplate = (JdbcTemplate) applicationContext.getBean("oracleJdbcTemplate");
        }
        if (!ObjectUtils.allNotNull(jdbcTemplate)) {
            jdbcTemplate = (JdbcTemplate) applicationContext.getBean("jdbcTemplate");
        }
        if(true){
            //1、执行sql：查询---> 中间库prisoner_main表，并且状态是0的数据，排除犯罪编号重复的数据，一次取500条。
            String mainSql = "SELECT * FROM PRISONER_MAIN WHERE STATE ='0' AND PRI_NUM NOT IN (SELECT PRI_NUM FROM PRISONER_MAIN pm WHERE PRI_NUM IS NOT NULL GROUP BY PRI_NUM HAVING COUNT(1)>1)  AND rownum <=500";
            List<Map<String,Object>> mainLists = oracleJdbcTemplate.queryForList(mainSql);
            Date date = new Date();
            CountDownLatch countDownLatch = new CountDownLatch(mainLists.size());
            //2、遍历主表数据，并且根据【对方的犯罪编号】查询出相关的服刑表、社会关系表、子女表、多媒体信息表
            for(Map<String,Object> mainMaps : mainLists) {
                //异步执行
                threadPoolConfig.taskExecutor().execute(() -> {
                    log.error("线程:{},开始异步处理:{}",Thread.currentThread().getName(),mainMaps.get("pri_num"));
                    checkTransform(mainMaps);
                    //前置机犯罪编号(对方)，用于查询子表，更新主表及子表及新增log日志表
                    String priNum = (String)mainMaps.get("pri_num");
                    String account = (String)mainMaps.get("account");
                    //安置帮教犯罪编号，用于判断是更新还是新增
                    String azbjPriNum = (String)mainMaps.get("azbj_prinum");
                    PrisonerMain prisonerMain = getPrisonerMain(mainMaps,date,account,azbjPriNum);
                    //2.执行服刑sql：根据【对方犯罪编号】查询---> 中间库prisoner_fx数据
                    String fxSql = "SELECT * FROM PRISONER_FX WHERE PRI_NUM = '" + priNum + "'";
                    List<Map<String,Object>> fxLists = oracleJdbcTemplate.queryForList(fxSql);
                    //2.1 处理PrisonerFx
                    //如果服刑信息为空，则返回错误
                    if(CollectionUtils.isEmpty(fxLists)) {
                        String updateMainSql = "UPDATE PRISONER_MAIN SET STATE = '2' WHERE PRI_NUM = '" + priNum + "'";
                        oracleJdbcTemplate.execute(updateMainSql);
                        //服刑表信息不能为空
                        String code = "999991";
                        insertMidLog(date,priNum,code,"");
                        countDownLatch.countDown();
                        return;
                    }
                    PrisonerFx prisonerFx = getPrisonerFx(fxLists,date,account);
                    //3.执行sql：根据【对方犯罪编号】查询---> 中间库prisoner_sr数据
                    String srSql = "SELECT * FROM PRISONER_SR WHERE PRI_NUM ='" + priNum + "'";
                    List<Map<String,Object>> srLists = oracleJdbcTemplate.queryForList(srSql);
                    List<PrisonerSr> prisonerSrs = getPrisonerSrs(srLists,date,account);
                    //4.执行sql：根据【对方犯罪编号】查询---> 中间库prisoner_zn数据
                    String znSql = "SELECT * FROM PRISONER_ZN WHERE PRI_NUM ='" + priNum + "'";
                    List<Map<String,Object>> znLists = oracleJdbcTemplate.queryForList(znSql);
                    List<PrisonerZn> prisonerZns = getPrisonerZns(znLists,date,account);
                    //5.执行sql：根据【对方犯罪编号】查询---> 中间库prisoner_multimedia数据
                    String mediaSql = "SELECT * FROM PRISONER_MULTIMEDIA WHERE PRI_NUM ='" + priNum + "'";
                    List<Map<String,Object>> mediaLists = oracleJdbcTemplate.queryForList(mediaSql);
                    List<MultimediaInfo> multimediaInfos = getMultimediaInfo(mediaLists);

                    //3.12 查询安置帮教系统中账号信息，并根据账号信息获取接口密钥
                    String sqluser = "SELECT tu.account,tu.username,tu.orgid,tu.uid,tu.orgid as pid,(SELECT name from tbsys_department where id=tu.orgid) as orgName,tu.departid,td.name AS departName,td.level,tu.position,tp.name AS positionName,tu.roleid,tr.name AS roleName,tu.unCheckField as unCheckField FROM tbsys_user_interface tu JOIN tbsys_department td ON tu.departid = td.id JOIN tbsys_position tp ON tu.position = tp.id JOIN tbsys_role tr ON tu.roleid = tr.id WHERE tu.account= '" + account + "'";
                    BeanPropertyRowMapper<UserInterFaceEntity> rowMapper = new BeanPropertyRowMapper<>(UserInterFaceEntity.class);
                    UserInterFaceEntity userInterface;
                    String signature;
                    long time = System.currentTimeMillis();
                    try {
                        userInterface = jdbcTemplate.queryForObject(sqluser,rowMapper);
                        String uid = userInterface.getUid();
                        String key = Hex.genAccessKey(uid);
                        //客户端自己生成密钥
                        signature = Hex.genSignature(key,String.valueOf(time),"/transmission/api/azbj/savePreArrangedPersonnel/");
                        //3.13、定义json对象，并添加下面节点
                        JSONObject jsonObject = new JSONObject();
                        jsonObject.put("time",String.valueOf(time));
                        jsonObject.put("sign",signature);
                        jsonObject.put("PrisonerMain",prisonerMain);
                        jsonObject.put("MultimediaInfo",multimediaInfos);
                        jsonObject.put("PrisonerFx",null == prisonerFx ? "" : prisonerFx);
                        jsonObject.put("PrisonerSr",prisonerSrs);
                        jsonObject.put("PrisonerZn",prisonerZns);
                        jsonObject.put("user",userInterface);
                        //3.14、定义返回结果
                        Result result;
                        String flag;
                        //3.15、调用service入库
                        if(StringUtils.isNotBlank(azbjPriNum)) {
                            //3.15.1、更新,如果中间库主表中的安置帮教犯罪编号不为空，说明是更新
                            result = dataTransmissionService.updatePreArrangedPersonnel(JSON.toJSON(jsonObject).toString());
                            flag = "update";
                        } else {
                            //3.15.2、新增,如果中间库主表中的安置帮教犯罪编号为空，说明是新数据，或者之前尝试插入安置帮教系统失败
                            result = dataTransmissionService.savePreArrangedPersonnel(JSON.toJSON(jsonObject).toString());
                            flag = "insert";
                        }
                        //3.16、根据返回结果，进行后续处理
                        if(Constants.Number.NUM_ONE.equals(result.getCode())) {
                            //3.16.1、成功，修改中间库主表状态state=1，更新各张表的安置帮教犯罪编号
                            String azbjPrinumSave = (String)result.getData();
                            String saveMain = "UPDATE PRISONER_MAIN SET STATE='1',AZBJ_PRINUM='" + azbjPrinumSave + "' WHERE PRI_NUM='" + priNum + "'";
                            String updateMain = "UPDATE PRISONER_MAIN SET UPDATE_STATE='2',AZBJ_PRINUM='" + azbjPrinumSave + "' WHERE PRI_NUM='" + priNum + "'";
                            String saveFx = "UPDATE PRISONER_FX SET AZBJ_PRINUM='" + azbjPrinumSave + "' WHERE PRI_NUM='" + priNum + "'";
                            String saveSr = "UPDATE PRISONER_SR SET AZBJ_PRINUM='" + azbjPrinumSave + "' WHERE PRI_NUM='" + priNum + "'";
                            String saveZn = "UPDATE PRISONER_ZN SET AZBJ_PRINUM='" + azbjPrinumSave + "' WHERE PRI_NUM='" + priNum + "'";
                            String saveMu = "UPDATE PRISONER_MULTIMEDIA SET AZBJ_PRINUM='" + azbjPrinumSave + "' WHERE PRI_NUM='" + priNum + "'";
                            if(StringUtils.equals("insert",flag)) {
                                oracleJdbcTemplate.execute(saveFx);
                                oracleJdbcTemplate.execute(saveSr);
                                oracleJdbcTemplate.execute(saveZn);
                                oracleJdbcTemplate.execute(saveMu);
                            }
                            if (StringUtils.equals("update", flag)) {
                                oracleJdbcTemplate.execute(updateMain);
                            }
                            oracleJdbcTemplate.execute(saveMain);
                            insertMidLog(date,priNum,Constants.NumberStr.NUM_STR_ZERO,azbjPrinumSave);
                        } else {
                            //3.34.3、失败，修改中间库主表状态state=2，把返回错误码，存储到中间库日志表
                            String code = result.getData().toString();
                            if(StringUtils.isBlank(code)) {
                                code = "999999";
                            }
                            String updateMainFalse = "UPDATE PRISONER_MAIN SET STATE='2' WHERE PRI_NUM='" + priNum + "'";
                            oracleJdbcTemplate.execute(updateMainFalse);
                            insertMidLog(date,priNum,code,"");
                        }
                    } catch(Exception e) {
                        log.error("发生异常{}",e.getMessage());
                        //3.34.3、发生异常，修改中间库主表状态state=2，把返回错误码，存储到中间库日志表
                        String mainEx = "UPDATE PRISONER_MAIN SET STATE='2' WHERE PRI_NUM='" + priNum + "'";
                        oracleJdbcTemplate.execute(mainEx);
                        insertMidLog(date,priNum,"999999","");
                    }finally {
                        countDownLatch.countDown();
                    }

                });
            }
            // 调用await()方法让主线程阻塞
            try {
                countDownLatch.await();
            } catch(InterruptedException e) {
                log.error("发生异常{}",e.getMessage());
            }
            long endTime = System.currentTimeMillis();
            log.info("\n>>>>>>>>>>>ending......从中间库同步预安置人员数据<<<<<<<<<<耗时:{}", (endTime - startTime) / 1000 / 60);
        } else {
            log.error("检测到数据源不可用,中间库对接Oracle版本任务失败! 时间"+formatTime.format(new Date()));
        }
    }

    /**
     * 核查成功之后-录入信息补录信息
     */
    @Async
    @Scheduled(cron = "${gkzx.azbj.outerInterface.db.gdOracle.bulucron}")
    public void predictWarningShadowTaskXXBU(){
        log.info("开启广东中间库多线程------------------信息补录开始");
        ApplicationContext applicationContext = BizApplication.applicationContext;
        if (!ObjectUtils.allNotNull(oracleJdbcTemplate)) {
            oracleJdbcTemplate = (JdbcTemplate) applicationContext.getBean("oracleJdbcTemplate");
        }
        if (!ObjectUtils.allNotNull(jdbcTemplate)) {
            jdbcTemplate = (JdbcTemplate) applicationContext.getBean("jdbcTemplate");
        }
        if(true){
            //多线程使用
            //1.执行sql去主表，核查表验证数据已经完成核查
            //2.执行sql(主表已经入安置系统,职业技能未进入安置系统),填充职业技能信息
            CompletableFuture.runAsync(()->{
                log.info("开启广东中间库多线程------------------职业技能信息拉取");
                long startTime = System.currentTimeMillis();
                String zyjnSql = "SELECT pz.*,pm.AZBJ_PRINUM main_Pri_num,pm.P_NAME pName FROM PRISONERS_ZYJN pz LEFT JOIN PRISONER_MAIN pm ON pm.PRI_NUM =pz.PRI_NUM WHERE pz.AZBJ_PRINUM is NULL and pm.AZBJ_PRINUM IS NOT NULL AND pm.STATE='1' AND  rownum <=500";
                List<Map<String,Object>> zyjnLists = oracleJdbcTemplate.queryForList(zyjnSql);
                //校验-封装-获取职业技能信息
                CountDownLatch countDownLatch = new CountDownLatch(zyjnLists.size());
                AtomicInteger atomicInteger = new AtomicInteger();
                for(Map<String,Object> zyjn : zyjnLists) {
                    //异步执行
                    threadPoolConfig.taskExecutor().execute(() -> {
                        Date date = new Date();
                        //校验参数为null的值
                        checkTransform(zyjn);
                        //校验职业技能参数
                        String type = (String)zyjn.get("TYPE");
                        String priNum = (String)zyjn.get("PRI_NUM");
                        String prientZyjn = (String)zyjn.get("PARENT_ZYJN");
                        String childZyjn = (String)zyjn.get("ZYJN");
                        String isAccept = (String)zyjn.get("IS_ACCEPT");
                        String certName = (String)zyjn.get("CERT_NAME");
                        //基础信息里面的安置帮教罪犯编号
                        String mainPriNum = (String)zyjn.get("MAIN_PRI_NUM");
                        StringBuilder initCode = new StringBuilder();
                        //1.判断安置系统中此编号人员是否核查成功
                        PrisonerHc prisonerHc = verificationService.getPrisonerHcByState(mainPriNum,Constants.NumberStr.NUM_STR_THREE);
                        if(prisonerHc != null){
                            log.info("{}------开始录入职业技能-----",zyjn.get("pName"));
                            //2.判断教育类型是否正确
                            if(StringUtils.isBlank(type)){
                                initCode.append(MiddleSqlReturnCode.ZYJN_JXLX_NULL.code());
                            }else{
                                switch(type){
                                    case Constants.NumberStr.NUM_STR_ZERO_ONE:;
                                        //2.1 判断基础教育
                                        if(!"".equals(prientZyjn)){
                                            initCode.append(MiddleSqlReturnCode.ZYJN_JXLX_PARTNT_ZYJN_NOTNULL_FALSE.code());
                                        } else {
                                            List<Map<String,String>> keyJcLists = searchCodeListService.getCodeNativeList(Constants.CodeType.CODE_JCJY,type);
                                            List<String> keyJcs = keyJcLists.stream().map(m -> m.get("id")).collect(Collectors.toList());
                                            if(!keyJcs.contains(childZyjn)){
                                                initCode.append(MiddleSqlReturnCode.ZYJN_JXLX_CHILD_JC_FALSE.code());
                                            } else {
                                                initCode.append(Constants.NumberStr.NUM_STR_ONE);
                                            }
                                        }
                                        break;
                                    case Constants.NumberStr.NUM_STR_ZERO_TWO:
                                        //2.2 判断学历教育
                                        if(!"".equals(prientZyjn)){
                                            initCode.append(MiddleSqlReturnCode.ZYJN_JXLX_PARTNT_ZYJN_NOTNULL_FALSE.code());
                                        } else {
                                            List<Map<String,String>> keyXlLists = searchCodeListService.getCodeNativeList(Constants.CodeType.CODE_JCJY,type);
                                            List<String> keyXLs = keyXlLists.stream().map(m -> m.get("id")).collect(Collectors.toList());
                                            if(!keyXLs.contains(childZyjn)) {
                                                initCode.append(MiddleSqlReturnCode.ZYJN_JXLX_CHILD_XL_FALSE.code());
                                            } else {
                                                initCode.append(Constants.NumberStr.NUM_STR_ONE);
                                            }
                                        }
                                        break;
                                    case Constants.NumberStr.NUM_STR_FU_ONE:
                                        //2.3 判断职业技能教育
                                        if(StringUtils.isBlank(prientZyjn)){
                                            initCode.append(MiddleSqlReturnCode.ZYJN_JXLX_PARTNT_ZYJN_NOTNULL_FALSE.code());
                                        }else{
                                            List<Map<String,String>> keyZyjnLists = searchCodeListService.getCodeNativeList(Constants.CodeType.CODE_JCJY,type);
                                            List<String> keyZyjns = keyZyjnLists.stream().map(m -> m.get("id")).collect(Collectors.toList());
                                            //职业技能分类的id 是否属于该教育类型
                                            if(!keyZyjns.contains(prientZyjn)) {
                                                initCode.append(MiddleSqlReturnCode.ZYJN_JXLX_PARTNT_ZYJN_FALSE.code());
                                            } else {
                                                List<Map<String, String>> childListKeys = searchCodeService.echozyjnValue(Constants.CodeType.CODE_JCJY, prientZyjn);
                                                List<String> childKeys = childListKeys.stream().map(m -> m.get("id")).collect(Collectors.toList());
                                                //职业技能 是否属于该职业技能分类管辖的范围
                                                if(!childKeys.contains(childZyjn)){
                                                    initCode.append(MiddleSqlReturnCode.ZYJN_JXLX_CHILD_ZYJN_FALSE.code());
                                                } else {
                                                    initCode.append(Constants.NumberStr.NUM_STR_ONE);
                                                }
                                            }
                                        }
                                        break;
                                    default: initCode.append(MiddleSqlReturnCode.ZYJN_JXLX_FALSE.code());
                                }
                            }
                            //判断是否获得证书是否在规定的编码中
                            if(StringUtils.containsAny(isAccept,Constants.NumberStr.NUM_STR_ZERO_ONE,Constants.NumberStr.NUM_STR_ZERO_TWO)){
                                if(Constants.NumberStr.NUM_STR_ZERO_ONE.equals(isAccept)){
                                    if(StringUtils.isBlank(certName)){
                                        initCode.append(MiddleSqlReturnCode.ZYJN_CRET_NAME_FALSE.code());
                                    }
                                }
                            }else{
                                initCode.append(MiddleSqlReturnCode.ZYJN_ISAccept_FALSE.code());
                            }
                        } else {
                            //此人员核查失败，写入日志
                            initCode.append(MiddleSqlReturnCode.PRINUM_CHECK_FALSE.code());
                        }
                        String code = initCode.toString();
                        if(Constants.NumberStr.NUM_STR_ONE.equals(code)){
                            //符合要求,封装职业技能，插入安置系统中
                            PrisonersZyjn prisonersZyjn = new PrisonersZyjn();
                            //根据罪犯编号查询核查表中核查人员姓名与账号
                            prisonersZyjn.setPriNum(mainPriNum);
                            prisonersZyjn.setType(type);
                            prisonersZyjn.setParentZyjn(prientZyjn);
                            prisonersZyjn.setZyjn(childZyjn);
                            prisonersZyjn.setIsAccept(isAccept);
                            prisonersZyjn.setCertName(certName);
                            UserDTO userDTO = new UserDTO();
                            userDTO.setAccount(prisonerHc.getCreateUser());
                            String zyjnString = JsonUtil.toText(prisonersZyjn);
                            Result result = xxblService.saveZyjnInfo(zyjnString,userDTO);
                            if(Constants.Number.NUM_ONE.equals(result.getCode())){
                                atomicInteger.getAndIncrement();
                                //执行成功时，去修改中间库的出监评估信息
                                String saveZyjn = "UPDATE PRISONERS_ZYJN SET AZBJ_PRINUM='" + mainPriNum + "' WHERE PRI_NUM='" + priNum + "'";
                                oracleJdbcTemplate.execute(saveZyjn);
                                //更改日志表
                                updateMidLog(date,code,mainPriNum);
                                log.info("{}------结束录入职业技能成功-----",zyjn.get("pName"));
                            }else{
                                updateMidLog(date,code,mainPriNum);
                            }
                        } else {
                            updateMidLog(date,code,mainPriNum);
                        }
                        countDownLatch.countDown();
                    });
                }
                // 调用await()方法让主线程阻塞
                try {
                    countDownLatch.await();
                } catch(InterruptedException e) {
                    log.info("------------------职业技能信息拉取--出现异常---------");
                    log.error("发生异常{}",e.getMessage());
                }finally {
                    long endTime = System.currentTimeMillis();
                    log.info("\n>>>>>>>>>>>ending......广东从中间库同步预安置人员数据-录入职业技能成功：{} 条<<<<<<<<<<耗时:{}", atomicInteger.get(),(endTime - startTime) / 1000 / 60);
                }
            },taskExecutor);
            //3.执行sql(主表已经入安置系统,减刑假释未进入安置系统),填充减刑假释信息
            CompletableFuture.runAsync(()->{
                long startTime = System.currentTimeMillis();
                AtomicInteger atomicInteger = new AtomicInteger();
                String jxjsSql = "SELECT jx.PRI_NUM,jx.SUB_RANGE,TO_CHAR(jx.PRI_STOP,'YYYY-mm-DD') as PRI_STOP,pm.AZBJ_PRINUM main_Pri_num,pm.P_NAME pName FROM PRISONERS_JXJS jx LEFT JOIN PRISONER_MAIN pm ON pm.PRI_NUM =jx.PRI_NUM WHERE jx.AZBJ_PRINUM is NULL and pm.AZBJ_PRINUM IS NOT NULL AND pm.STATE='1' AND  rownum <=500";
                List<Map<String,Object>> jxjsLists = oracleJdbcTemplate.queryForList(jxjsSql);
                //校验-封装-获取减刑假释信息
                CountDownLatch countDownLatch = new CountDownLatch(jxjsLists.size());
                jxjsLists.forEach(jxjs->{
                    //异步执行
                    threadPoolConfig.taskExecutor().execute(() -> {
                        Date date = new Date();
                        //校验参数为null的值
                        checkTransform(jxjs);
                        //校验减刑假释参数
                        String priNum = (String)jxjs.get("PRI_NUM");
                        String mainPriNum = (String)jxjs.get("MAIN_PRI_NUM");
                        String subRange = (String)jxjs.get("SUB_RANGE");
                        //现刑期
                        String priStopNowDate = (String)jxjs.get("PRI_STOP");
                        //从服刑表中获取原来的刑期起日与止日
                        PrisonerFx prisonerFx = xxblService.selectJxjsPriStopInfo(mainPriNum);
                        Date priBegin = prisonerFx.getPriBegin();
                        Date priStop = prisonerFx.getPriStop();
                        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
                        String priStopStr = simpleDateFormat.format(priStop);
                        //1.判断安置系统中此编号人员是否核查成功
                        PrisonerHc prisonerHc = verificationService.getPrisonerHcByState(mainPriNum,Constants.NumberStr.NUM_STR_THREE);
                        StringBuilder initCode = new StringBuilder();
                        if(prisonerHc != null){
                            log.info("{}------开始录入减刑假释-----",jxjs.get("pName"));
                            //2.判断现刑期类型是否正确
                            if(StringUtils.isBlank(subRange)){
                                initCode.append(MiddleSqlReturnCode.JXJS_XXQLXCODE_NULL.code());
                            }else {
                                //现刑期类型是否符合编码
                                if(StringUtils.equalsAny(subRange,Constants.PritimeTypeNow.PRITIME_YOUQI,Constants.PritimeTypeNow.PRITIME_WUQI,Constants.PritimeTypeNow.PRITIME_SIHUAN,Constants.PritimeTypeNow.PRITIME_SIXING)){
                                    //区分有期徒刑和其他，分别进行校验和设置值
                                    if(subRange.equals(Constants.PritimeTypeNow.PRITIME_YOUQI)){
                                        if(StringUtils.isBlank(priStopNowDate)){
                                            initCode.append(MiddleSqlReturnCode.JXJS_XXQZR_IS_NULL.code());
                                        } else {
                                            //注意月份是MM
                                            try {
                                                //转换现刑期格式
                                               Date priStopNowFormat = simpleDateFormat.parse(priStopNowDate);
                                                if(priBegin.after(priStopNowFormat)) {
                                                    initCode.append(MiddleSqlReturnCode.JXJS_XX_IS_ERROR.code());
                                                } else {
                                                    initCode.append(Constants.NumberStr.NUM_STR_TWO);
                                                }
                                            } catch(ParseException e) {
                                                log.info("数据类型转换异常----------》减刑假释");
                                                countDownLatch.countDown();
                                                return;
                                            }
                                        }
                                    }else {
                                        log.info("非正常释放----------》减刑假释");
                                        initCode.append(Constants.NumberStr.NUM_STR_TWO);
                                    }
                                } else {
                                    initCode.append(MiddleSqlReturnCode.JXJS_XXQLXCODE_IS_ERROR.code());
                                }
                            }
                        } else {
                            //此人员核查失败，写入日志
                            initCode.append(MiddleSqlReturnCode.PRINUM_CHECK_FALSE.code());
                        }
                        String code = initCode.toString();
                        //校验无错，封装数据，保存
                        if(Constants.NumberStr.NUM_STR_TWO.equals(code)){
                            UserDTO userDTO = new UserDTO();
                            userDTO.setUsername(prisonerHc.getStartCheckPerson());
                            Map<String,Object> map = new HashMap<>();
                            map.put("priStop",priStopNowDate);
                            map.put("subRange",subRange);
                            map.put("priNum",mainPriNum);
                            map.put("pristopold",priStopStr);
                            try {
                                Result result = xxblService.saveJxjsInfo(map,userDTO);
                                if(result.getCode().equals(Constants.Number.NUM_ONE)){
                                    atomicInteger.getAndIncrement();
                                    //执行成功时，去修改中间库的出监评估信息
                                    String saveJxjs = "UPDATE PRISONERS_JXJS SET AZBJ_PRINUM='" + mainPriNum + "' WHERE PRI_NUM='" + priNum + "'";
                                    oracleJdbcTemplate.execute(saveJxjs);
                                    //更改日志表
                                    updateMidLog(date,code,mainPriNum);
                                    log.info("{}------结束录入减刑假释成功-----",jxjs.get("pName"));
                                } else {
                                    log.info("广东中间库-保存减刑假释时失败------》减刑假释");
                                }
                            } catch(ParseException e) {
                                log.info("数据类型转换异常----保存减刑假释时------》减刑假释");
                                countDownLatch.countDown();
                                return;
                            }
                        } else {
                            //更改日志表
                            updateMidLog(date,code,mainPriNum);
                        }
                        countDownLatch.countDown();
                    });
                });
                // 调用await()方法让主线程阻塞
                try {
                    countDownLatch.await();
                } catch(InterruptedException e) {
                    log.info("------------------减刑假释信息拉取--出现异常---------");
                    log.error("发生异常{}",e.getMessage());
                }finally {
                    long endTime = System.currentTimeMillis();
                    log.info("\n>>>>>>>>>>>ending......广东从中间库同步预安置人员数据-录入减刑假释成功：{} 条<<<<<<<<<<耗时:{}", atomicInteger.get(),(endTime - startTime) / 1000 / 60);
                }
                },taskExecutor);

            //4.执行sql(主表已经入安置系统,出监评估未进入安置系统),填充出监评估信息
            CompletableFuture.runAsync(()->{
                long startTime = System.currentTimeMillis();
                String cjpg = "SELECT cg.*,pm.AZBJ_PRINUM main_Pri_num,pm.P_NAME pName FROM PRISONER_CJPG cg LEFT JOIN PRISONER_MAIN pm ON pm.PRI_NUM =cg.PRI_NUM WHERE cg.AZBJ_PRINUM is NULL and pm.AZBJ_PRINUM IS NOT NULL AND pm.STATE='1' AND  rownum <=500";
                List<Map<String,Object>> cjpgLists = oracleJdbcTemplate.queryForList(cjpg);
                //校验-封装-获取出监评估信息
                CountDownLatch countDownLatch = new CountDownLatch(cjpgLists.size());
                AtomicInteger atomicInteger = new AtomicInteger();
                cjpgLists.forEach(cjpgDemo->{
                    threadPoolConfig.taskExecutor().execute(() -> {
                        Date date = new Date();
                        //校验参数为null的值
                        checkTransform(cjpgDemo);
                        //获取安置系统罪犯人员服刑编号
                        String mainPriNum = (String)cjpgDemo.get("MAIN_PRI_NUM");
                        String priNum = (String)cjpgDemo.get("PRI_NUM");
                        Map<String,Object> map=null;
                        //判断成功标识
                        StringBuilder cjpgCode = new StringBuilder();
                        //1.判断安置系统中此编号人员是否核查成功
                        PrisonerHc prisonerHc = verificationService.getPrisonerHcByState(mainPriNum,Constants.NumberStr.NUM_STR_THREE);
                        StringBuilder initCode = new StringBuilder();
                        if(prisonerHc != null){
                            log.info("{}------开始录入出监评估-----",cjpgDemo.get("pName"));
                            //校验出监评估参数
                            map = checkCjpg(cjpgDemo,cjpgCode,mainPriNum);
                            cjpgCode = (StringBuilder)map.get("code");
                        } else {
                            //此人员核查失败，写入日志
                            cjpgCode.append(MiddleSqlReturnCode.PRINUM_CHECK_FALSE.code());
                        }
                        String code = cjpgCode.toString();
                        //校验无错，封装出监评估数据，保存
                        if(Constants.NumberStr.NUM_STR_THREE.equals(code)){
                            //1.根据犯罪编号查询prisoner_cjpg表是否存在数据
                            PrisonerCjpg prisonerCjpg = xxblService.selectCjpgInfoByPrNum(mainPriNum);
                            String account = prisonerHc.getCreateUser();
                            map.put("priNum",prisonerHc.getPriNum());
                            Result cjpgResult;
                            if(null != prisonerCjpg){
                                //更改
                                map.put("updateUser",account);
                                map.put("updateTime",new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date));
                                cjpgResult = xxblService.updateCjpg(map);
                            } else {
                                //新增
                                UserDTO userDTO = new UserDTO();
                                userDTO.setAccount(account);
                                String userDTOstr = JsonUtil.toText(userDTO);
                                map.put("userDTO",userDTOstr);
                                cjpgResult = prisonerMainService.insertCjpg(map);
                            }
                            //2.prisoner_cjpg表处理成功后，更新服刑表
                            if(Constants.Number.NUM_ONE.equals(cjpgResult.getCode())) {
                                Result result = xxblService.saveWxxpgInfo(JsonUtil.toText(map));
                                if(Constants.Number.NUM_ONE.equals(result.getCode())){
                                    String cjTaskId = (String)map.get("cjTaskId");
                                    // 1.判断是否有附件（出监评估）
                                    if(Constants.NumberStr.NUM_STR_TWO.equals(cjTaskId)){
                                        //1.ftp获取文件内容以及详细信息(对方的ftp)
                                        FTPClient gdFtp = gdFtpUtil.getFTPClientGd();
                                        //ftp:主目录+出监评估附件目录+罪犯编号
                                        String gdFilePath = gdFtpUtil.getFtpFzpgPath(priNum);
                                        //转移到FTP服务器目录
                                        try {
                                            gdFtp.changeWorkingDirectory(gdFilePath);
                                            FTPFile[] fs = gdFtp.listFiles();
                                            for(FTPFile ff : fs) {
                                                long next = IdGen.get().next();
                                                //名字需要做一下
                                                String name = ff.getName();
                                                //获取文件类型
                                                String type = name.substring(name.lastIndexOf("."));
                                                //重新创建上传文件属性
                                                String filename = next + type;
                                                String uploadFilePath = FileUtil.getUploadFilePath();
                                                //本地附件文件上传的位置
                                                String fileAbstractPath = uploadFilePath + account + File.separator + filename;
                                                File localFile = new File(fileAbstractPath);
                                                if(localFile.exists()) {
                                                    log.info("{}--本地附件已经存在");
                                                    continue;
                                                } else {
                                                    PrisonerMain prisonerMain = verificationService.getPrisonerMainByPriNum(mainPriNum);
                                                    PrisonerFx prisonerFx = xxblService.selectJxjsPriStopInfo(mainPriNum);
                                                    UploadAppendixFile uploadAppendixFile = new UploadAppendixFile();
                                                    uploadAppendixFile.setId(prisonerFx.getId());
                                                    uploadAppendixFile.setPriNum(mainPriNum);
                                                    uploadAppendixFile.setSingleId(com.sinog.core.utilbean.IdGen.strid());
                                                    uploadAppendixFile.setAccount(account);
                                                    uploadAppendixFile.setUserName(prisonerHc.getStartCheckPerson());
                                                    uploadAppendixFile.setUploadDate(date);
                                                    uploadAppendixFile.setTaskId(Constants.NumberStr.NUM_STR_ONE);
                                                    uploadAppendixFile.setFileName(name);
                                                    uploadAppendixFile.setFileUrl(account + File.separator + filename);
                                                    OutputStream out = new FileOutputStream(localFile);
                                                    // 4.1、将文件上传到本地服务器
                                                    boolean b = gdFtp.retrieveFile(name,out);
                                                    if(b){
                                                        if(localFile.exists()) {
                                                            Integer integer = uploadAppendixFileFeignService.saveAppendixFileData(uploadAppendixFile);
                                                            if(Constants.Number.NUM_ZERO < integer){
                                                                // 4.2、将文件上传到ftp服务器
                                                                asyncUploadFileToFtp.uploadFileToFtp(datapath + account,fileAbstractPath);
                                                                log.info("{}------结束录入出监评估成功-----",cjpgDemo.get("pName"));
                                                            } else {
                                                                log.error("文件信息保存失败！");
                                                                countDownLatch.countDown();
                                                                throw new RuntimeException();
                                                            }
                                                        }
                                                    } else {
                                                        log.info("{}---本地附件上传文件失败----",prisonerMain.getPName());
                                                    }
                                                    out.flush();
                                                    out.close();

                                                }
                                            }
                                        } catch(IOException e) {
                                            log.info("{}------录入出监评估异常-----",cjpgDemo.get("pName"));
                                            log.info("出现异常：{}",e);
                                            countDownLatch.countDown();
                                            throw new RuntimeException(e);
                                        } finally {
                                            FtpUtil.closeFtpClient(gdFtp);
                                        }
                                    }
                                    //执行成功时，去修改中间库的出监评估信息
                                    atomicInteger.getAndIncrement();
                                    String saveJxjs = "UPDATE PRISONER_CJPG SET AZBJ_PRINUM='" + mainPriNum + "' WHERE PRI_NUM='" + priNum + "'";
                                    oracleJdbcTemplate.execute(saveJxjs);
                                    updateMidLog(date,code,mainPriNum);
                                } else {
                                    log.info("广东中间库-保存出监评估时失败------》出监评估");
                                }
                            } else {
                                log.info("广东中间库-保存出监评估时失败------》出监评估");
                            }
                        } else {
                            updateMidLog(date,code,mainPriNum);
                        }
                        countDownLatch.countDown();
                    });
                });
                // 调用await()方法让主线程阻塞
                try {
                    countDownLatch.await();
                } catch(InterruptedException e) {
                    log.info("------------------出监评估信息拉取--出现异常---------");
                    log.error("发生异常{}",e.getMessage());
                }finally {
                    long endTime = System.currentTimeMillis();
                    log.info("\n>>>>>>>>>>>ending......广东从中间库同步预安置人员数据-录入出监评估成功：{} 条<<<<<<<<<<耗时:{}", atomicInteger.get(),(endTime - startTime) / 1000 / 60);
                }
            },taskExecutor);
        }
    }
    /**
     * 校验出监评估参数
     * @param cjpgDemo
     */
    private Map<String,Object> checkCjpg(Map<String,Object> cjpgDemo,StringBuilder cjpgCode,String priNum) {
        //校验-是否特赦 1是 2否
        String amnesty = (String)cjpgDemo.get("AMNESTY");
        //校验-服刑期间再犯罪 1是2否
        String zfz = (String)cjpgDemo.get("ZFZ");
        //校验-死亡 1是2否
        String death = (String)cjpgDemo.get("DEATH");
        //校验-转入社区矫正 1是2否
        String zrSqjz = (String)cjpgDemo.get("ZRSQJZ");
        //校验-是否五涉 1是2否
        String whShe = (String)cjpgDemo.get("WUSHE");
        //涉恐 涉邪 涉毒 涉枪 涉黑恶
        String sheKong = (String)cjpgDemo.get("SHEKONG");
        String sheXie = (String)cjpgDemo.get("SHEXIE");
        String sheDu = (String)cjpgDemo.get("SHEDU");
        String sheQiang = (String)cjpgDemo.get("SHEQIANG");
        String sheHei = (String)cjpgDemo.get("SHEHEI");
        //校验-是否四史 1是2否
        String siShi = (String)cjpgDemo.get("SISHI");
        //袭警史 逃脱史 吸毒史 自杀史
        String xiJing = (String)cjpgDemo.get("XIJING");
        String taoTuo = (String)cjpgDemo.get("TAOTUO");
        String drughis = (String)cjpgDemo.get("DRUGHIS");
        String ziSha = (String)cjpgDemo.get("ZISHA");
        //校验-改造表现 1好 2较好 3一般 4较差 5差
        String gaiZao = (String)cjpgDemo.get("GAIZAO");
        //校验-认罪态度 1认罪服法 2服管不认罪 3不认罪不服管
        String renZui = (String)cjpgDemo.get("RENZUI");
        //校验-是否心理健康 1是 2否
        String xinLi = (String)cjpgDemo.get("XINLI");
        //校验-家庭联系情况 1家庭有联系 2家庭无联系 3离异
        String lianXi = (String)cjpgDemo.get("LIANXI");
        //校验-是否办理保外就医 1是 2否
        String baoWaiJiuYi = (String)cjpgDemo.get("BAOWAIJIUYI");
        //校验-是否三无 1是 2否
        String sanWu = (String)cjpgDemo.get("SANWU");
        //无家可归 无亲可投 无业可就
        String wuJia = (String)cjpgDemo.get("WUJIA");
        String wuQin = (String)cjpgDemo.get("WUQIN");
        String wuYe = (String)cjpgDemo.get("WUYE");
        //校验-是否三假 1是 2否
        String sanJia = (String)cjpgDemo.get("SANJIA");
        //假姓名 假身份 假住址
        String jxm = (String)cjpgDemo.get("JXM");
        String jsf = (String)cjpgDemo.get("JSF");
        String jhj = (String)cjpgDemo.get("JHJ");
        //校验-是否有违法犯罪倾向 1是 2否
        String weiFa = (String)cjpgDemo.get("WEIFA");
        //校验残疾-是否重大疾病、残疾 1是 2否
        String canji = (String)cjpgDemo.get("CANJI");
        //校验-有无固定住所 0有 1无
        String gdzs = (String)cjpgDemo.get("GDZS");
        //校验-社会交往 01 不复杂 02 复杂
        String shjw = (String)cjpgDemo.get("SHJW");
        //校验-家庭变化
        String jtbh = (String)cjpgDemo.get("JTBH");
        //校验-刑释后可能遇到的困难
        String xshKn = (String)cjpgDemo.get("XSHKN");
        //校验-初步帮教、救助建议
        String jiuZhiJianYi = (String)cjpgDemo.get("JIUZHUJIANYI");
        //校验-释放后是否戒毒 1是 2否
        String xd = (String)cjpgDemo.get("XD");
        // 附件标识4:改造表现1:无2:有
        String gzTaskId = (String)cjpgDemo.get("GZ_TASK_ID");
        // 附件标识5:心里健康1:无2:有
        String xlTaskId = (String)cjpgDemo.get("XL_TASK_ID");
        // 附件标识1:出监评估1:无2:有
        String cjTaskId = (String)cjpgDemo.get("CJ_TASK_ID");

        if(!StringUtils.equalsAny(amnesty.trim(),Constants.NumberStr.NUM_STR_ONE,Constants.NumberStr.NUM_STR_TWO)){
            cjpgCode.append(MiddleSqlReturnCode.JCPG_TS_IS_ERROR.code());
        }
        if(!StringUtils.equalsAny(zfz.trim(),Constants.NumberStr.NUM_STR_ONE,Constants.NumberStr.NUM_STR_TWO)){
            cjpgCode.append(MiddleSqlReturnCode.JCPG_ZFZ_IS_ERROR.code());
        }
        if(!StringUtils.equalsAny(death.trim(),Constants.NumberStr.NUM_STR_ONE,Constants.NumberStr.NUM_STR_TWO)){
            cjpgCode.append(MiddleSqlReturnCode.JCPG_DEATH_IS_ERROR.code());
        }
        if(!StringUtils.equalsAny(zrSqjz.trim(),Constants.NumberStr.NUM_STR_ONE,Constants.NumberStr.NUM_STR_TWO)){
            cjpgCode.append(MiddleSqlReturnCode.JCPG_ZRSQJZ_IS_ERROR.code());
        }
        if(StringUtils.equalsAny(whShe.trim(),Constants.NumberStr.NUM_STR_ONE,Constants.NumberStr.NUM_STR_TWO)){
            if(whShe.trim().equals(Constants.NumberStr.NUM_STR_ONE)){
                //如果有五赦，这些五项至少有一个为true
                if(!StringUtils.equalsAny(Constants.StrFinalValue.TRUEVALUE,sheKong,sheXie,sheDu,sheQiang,sheHei)){
                    cjpgCode.append(MiddleSqlReturnCode.JCPG_WS_TRUE_ERROR.code());
                }
            } else {
                //如果没有五赦，这些五项全部为false
                boolean whSheFlag = Constants.StrFinalValue.FALSEVALUE.equals(sheKong)
                        && Constants.StrFinalValue.FALSEVALUE.equals(sheXie)
                        && Constants.StrFinalValue.FALSEVALUE.equals(sheDu)
                        && Constants.StrFinalValue.FALSEVALUE.equals(sheQiang)
                        && Constants.StrFinalValue.FALSEVALUE.equals(sheHei);
                if(!whSheFlag){
                    cjpgCode.append(MiddleSqlReturnCode.JCPG_WS_FALSE_ERROR.code());
                }

            }
        } else {
            cjpgCode.append(MiddleSqlReturnCode.JCPG_WS_IS_ERROR.code());
        }
        if(StringUtils.equalsAny(siShi.trim(),Constants.NumberStr.NUM_STR_ONE,Constants.NumberStr.NUM_STR_TWO)){
            if(siShi.trim().equals(Constants.NumberStr.NUM_STR_ONE)){
                //如果有四史，这些四项至少有一个为true
                if(!StringUtils.equalsAny(Constants.StrFinalValue.TRUEVALUE,xiJing,taoTuo,drughis,ziSha)){
                    cjpgCode.append(MiddleSqlReturnCode.JCPG_WS_TRUE_ERROR.code());
                }
            } else {
                //如果没有四史，这些四项全部为false
                boolean siShiFlag = Constants.StrFinalValue.FALSEVALUE.equals(xiJing)
                        && Constants.StrFinalValue.FALSEVALUE.equals(taoTuo)
                        && Constants.StrFinalValue.FALSEVALUE.equals(drughis)
                        && Constants.StrFinalValue.FALSEVALUE.equals(ziSha);
                if(!siShiFlag){
                    cjpgCode.append(MiddleSqlReturnCode.JCPG_WS_FALSE_ERROR.code());
                }
            }
        } else {
            cjpgCode.append(MiddleSqlReturnCode.JCPG_SS_IS_ERROR.code());
        }
        if(!StringUtils.equalsAny(gaiZao.trim(),Constants.NumberStr.NUM_STR_ONE,Constants.NumberStr.NUM_STR_TWO,Constants.NumberStr.NUM_STR_THREE,Constants.NumberStr.NUM_STR_FOUR,Constants.NumberStr.NUM_STR_FIVE)){
            cjpgCode.append(MiddleSqlReturnCode.JCPG_GZ_IS_ERROR.code());
        }
        if(!StringUtils.equalsAny(renZui.trim(),Constants.NumberStr.NUM_STR_ONE,Constants.NumberStr.NUM_STR_TWO,Constants.NumberStr.NUM_STR_THREE)){
            cjpgCode.append(MiddleSqlReturnCode.JCPG_RZ_IS_ERROR.code());
        }
        if(!StringUtils.equalsAny(xinLi.trim(),Constants.NumberStr.NUM_STR_ONE,Constants.NumberStr.NUM_STR_TWO)){
            cjpgCode.append(MiddleSqlReturnCode.JCPG_XLJK_IS_ERROR.code());
        }
        if(!StringUtils.equalsAny(lianXi.trim(),Constants.NumberStr.NUM_STR_ONE,Constants.NumberStr.NUM_STR_TWO,Constants.NumberStr.NUM_STR_THREE)){
            cjpgCode.append(MiddleSqlReturnCode.JCPG_JTLX_IS_ERROR.code());
        }
        if(!StringUtils.equalsAny(baoWaiJiuYi.trim(),Constants.NumberStr.NUM_STR_ONE,Constants.NumberStr.NUM_STR_TWO)){
            cjpgCode.append(MiddleSqlReturnCode.JCPG_BWJY_IS_ERROR.code());
        }
        if(StringUtils.equalsAny(sanWu.trim(),Constants.NumberStr.NUM_STR_ONE,Constants.NumberStr.NUM_STR_TWO)){
            if(sanWu.trim().equals(Constants.NumberStr.NUM_STR_ONE)){
                //如果有三无，这些三项至少有一个为true
                if(!StringUtils.equalsAny(Constants.StrFinalValue.TRUEVALUE,wuJia,wuQin,wuYe)){
                    cjpgCode.append(MiddleSqlReturnCode.JCPG_SW_TRUE_ERROR.code());
                }
            } else {
                //如果没有三无，这些三项全部为false
                boolean sanWuFlag = Constants.StrFinalValue.FALSEVALUE.equals(wuJia)
                        && Constants.StrFinalValue.FALSEVALUE.equals(wuQin)
                        && Constants.StrFinalValue.FALSEVALUE.equals(wuYe);
                if(!sanWuFlag){
                    cjpgCode.append(MiddleSqlReturnCode.JCPG_SW_FALSE_ERROR.code());
                }
            }
        } else {
            cjpgCode.append(MiddleSqlReturnCode.JCPG_SW_IS_ERROR.code());
        }
        if(StringUtils.equalsAny(sanJia.trim(),Constants.NumberStr.NUM_STR_ONE,Constants.NumberStr.NUM_STR_TWO)){
            //如果有三假，这些三项至少有一个为true
            if(sanJia.trim().equals(Constants.NumberStr.NUM_STR_ONE)){
                if(!StringUtils.equalsAny(Constants.StrFinalValue.TRUEVALUE,jxm,jsf,jhj)){
                    cjpgCode.append(MiddleSqlReturnCode.JCPG_SJ_TRUE_ERROR.code());
                }
            } else {
                //如果没有三无，这些三项全部为false
                boolean sanWuFlag = Constants.StrFinalValue.FALSEVALUE.equals(jxm)
                        && Constants.StrFinalValue.FALSEVALUE.equals(jsf)
                        && Constants.StrFinalValue.FALSEVALUE.equals(jhj);
                if(!sanWuFlag){
                    cjpgCode.append(MiddleSqlReturnCode.JCPG_SW_FALSE_ERROR.code());
                }
            }
        } else {
            cjpgCode.append(MiddleSqlReturnCode.JCPG_SJ_IS_ERROR.code());
        }
        if(!StringUtils.equalsAny(weiFa.trim(),Constants.NumberStr.NUM_STR_ONE,Constants.NumberStr.NUM_STR_TWO)){
            cjpgCode.append(MiddleSqlReturnCode.JCPG_WFFZ_IS_ERROR.code());
        }
        if(!StringUtils.equalsAny(canji.trim(),Constants.NumberStr.NUM_STR_ONE,Constants.NumberStr.NUM_STR_TWO)){
            cjpgCode.append(MiddleSqlReturnCode.JCPG_CJ_IS_ERROR.code());
        }
        if(!StringUtils.equalsAny(gdzs.trim(),Constants.NumberStr.NUM_STR_ZERO,Constants.NumberStr.NUM_STR_ONE)){
            cjpgCode.append(MiddleSqlReturnCode.JCPG_CJ_IS_ERROR.code());
        }
        if(!StringUtils.equalsAny(shjw.trim(),Constants.NumberStr.NUM_STR_ZERO_ONE,Constants.NumberStr.NUM_STR_ZERO_TWO)){
            cjpgCode.append(MiddleSqlReturnCode.JCPG_SHJW_IS_ERROR.code());
        }
        if(!StringUtils.equalsAny(xd.trim(),Constants.NumberStr.NUM_STR_ONE,Constants.NumberStr.NUM_STR_TWO)){
            cjpgCode.append(MiddleSqlReturnCode.JCPG_XD_IS_ERROR.code());
        }
        if(!StringUtils.equalsAny(gzTaskId.trim(),Constants.NumberStr.NUM_STR_ONE,Constants.NumberStr.NUM_STR_TWO)){
            cjpgCode.append(MiddleSqlReturnCode.JCPG_GZTASK_IS_ERROR.code());
        }
        if(!StringUtils.equalsAny(xlTaskId.trim(),Constants.NumberStr.NUM_STR_ONE,Constants.NumberStr.NUM_STR_TWO)){
            cjpgCode.append(MiddleSqlReturnCode.JCPG_XLTASK_IS_ERROR.code());
        }
        if(!StringUtils.equalsAny(cjTaskId.trim(),Constants.NumberStr.NUM_STR_ONE,Constants.NumberStr.NUM_STR_TWO)){
            cjpgCode.append(MiddleSqlReturnCode.JCPG_CJPGTASK_IS_ERROR.code());
        }
        Map<String, Object> map = new HashMap<>(16);
        //----出监评估需要的属性
        map.put("sfywffzqx",weiFa);
        //校验残疾-是否重大疾病、残疾 1是 2否(服刑也有)
        map.put("canji",canji);
        //校验-有无固定住所 0有 1无
        map.put("gdzs",gdzs);
        //校验-社会交往 01 不复杂 02 复杂
        map.put("shjw",shjw);
        //校验-刑释后可能遇到的困难
        map.put("xshkn",xshKn);
        //校验-家庭变化
        map.put("jtbh",jtbh);
        //校验-初步帮教、救助建议
        map.put("jiuzhujianyi",jiuZhiJianYi);
        //校验-释放后是否戒毒 1是 2否
        map.put("xd",xd);
        //----服刑需要资源的属性
        //校验-是否特赦 1是 2否
        map.put("amnesty",amnesty);
        //校验-服刑期间再犯罪 1是2否
        map.put("zfz",zfz);
        //校验-死亡 1是2否
        map.put("death",death);
        //校验-转入社区矫正 1是2否
        map.put("zrsqjz",zrSqjz);
        //校验-是否五涉 1是2否
        map.put("wushe",whShe);
        //涉恐 涉邪 涉毒 涉枪 涉黑恶
        map.put("shekong",sheKong);
        map.put("shexie",sheXie);
        map.put("shedu",sheDu);
        map.put("sheqiang",sheQiang);
        map.put("shehei",sheHei);
        //校验-是否四史 1是2否
        map.put("sishi",siShi);
        //袭警史 逃脱史 吸毒史 自杀史
        map.put("xijing",xiJing);
        map.put("taotuo",taoTuo);
        map.put("drughis",drughis);
        map.put("zisha",ziSha);
        //校验-改造表现 1好 2较好 3一般 4较差 5差
        map.put("gaizao",gaiZao);
        //校验-认罪态度 1认罪服法 2服管不认罪 3不认罪不服管
        map.put("renzui",renZui);
        //校验-是否心理健康 1是 2否
        map.put("xinli",xinLi);
        //校验-家庭联系情况 1家庭有联系 2家庭无联系 3离异
        map.put("lianxi",lianXi);
        //校验-是否办理保外就医 1是 2否
        map.put("baowaijiuyi",baoWaiJiuYi);
        //校验-是否三无 1是 2否
        map.put("sanwu",sanWu);
        //无家可归 无亲可投 无业可就
        map.put("wujia",wuJia);
        map.put("wuqin",wuQin);
        map.put("wuye",wuYe);
        //校验-是否三假 1是 2否
        map.put("sanjia",sanJia);
        //假姓名 假身份 假住址
        map.put("jxm",jxm);
        map.put("jsf",jsf);
        map.put("jhj",jhj);
        //校验-是否有违法犯罪倾向 1是 2否
        map.put("weifa",weiFa);
        // 附件标识4:改造表现1:无2:有
        map.put("gzTaskId",gzTaskId);
        // 附件标识5:心里健康1:无2:有
        map.put("xlTaskId",xlTaskId);
        // 附件标识1:出监评估1:无2:有
        map.put("cjTaskId",cjTaskId);
        PrisonerFx prisonerFx = xxblService.selectJxjsPriStopInfo(priNum);
        if(StringUtils.equalsAny(Constants.NumberStr.NUM_STR_ONE,sanWu.trim(),sanJia.trim(),weiFa.trim(),prisonerFx.getAftype())){
            map.put("pinggu",Constants.NumberStr.NUM_STR_ZERO_ONE);
        }else{
            map.put("pinggu",Constants.NumberStr.NUM_STR_ZERO_TWO);
        }
        if(StringUtils.isBlank(cjpgCode.toString())){
            cjpgCode.append(Constants.NumberStr.NUM_STR_THREE);
        }
        map.put("code",cjpgCode);
        return map;
    }

    /**
     * 将错误码保存反馈日志表中
     * @param date 日期
     * @param priNum （对方的）犯罪编号
     * @param code 错误码
     * @param azbjPriNum 安置帮教犯罪编号（正确添值，错误为空字符串）
     */
    private void insertMidLog(Date date,String priNum,String code,String azbjPriNum){
        String saveLog = "INSERT INTO PRISONER_MIDDLE_LOG (PRI_NUM, CODE, CREATE_TIME, UPDATE_TIME, AZBJ_PRINUM)";
        StringBuilder saveLogBuilder = new StringBuilder(saveLog);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String format = simpleDateFormat.format(date);
        saveLogBuilder.append("values (").append("\'").append(priNum).append("\',\'").append(code)
                      .append("\',to_date(\'").append(format).append("\',").append("\'").append("YYYY-MM-DD HH24:MI:SS").append("\'")
                      .append("),to_date(\'").append(format).append("\',").append("\'").append("YYYY-MM-DD HH24:MI:SS").append("\'),\'")
                      .append(azbjPriNum).append("\'").append(")");
        oracleJdbcTemplate.execute(saveLogBuilder.toString());
    }
    /**
     * 信息补录，修改反馈日志表
     * @param date 修改日期
     * @param code 修改标识
     * @param azbjPriNum 安置帮教罪犯人员编号
     */
    private void updateMidLog(Date date,String code,String azbjPriNum){
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String format = simpleDateFormat.format(date);
        String saveLog = "UPDATE PRISONER_MIDDLE_LOG SET CODE = ";
        StringBuilder saveLogBuilder = new StringBuilder(saveLog);
        saveLogBuilder.append("\'").append(code).append("\'").append(",UPDATE_TIME = ").append("to_date(\'").append(format).append("\',").append("\'").append("YYYY-MM-DD HH24:MI:SS").append("\'")
                .append(")").append(" where AZBJ_PRINUM=").append("\'").append(azbjPriNum).append("\'");
        oracleJdbcTemplate.execute(saveLogBuilder.toString());
    }
    /**
     * 把value为null的置为""，避免后面报错
     * @param maps 信息属性集合
     */
    private void checkTransform(Map<String,Object> maps){
        for(String key : maps.keySet()) {
            Object value = maps.get(key);
            if(ObjectUtils.allNull(value) && !key.equals("AGE")) {
                maps.put(key,"");
            }
        }
    }
    /**
     * 获取基本信息
     * @param mainMaps 中间库查询-基本信息集合
     * @param date 创建与更新时间
     * @param account 用户账号
     * @param azbjPriNum 安置罪犯人员编号
     * @return PrisonerMain
     */
    private PrisonerMain getPrisonerMain(Map<String,Object> mainMaps,Date date,String account,String azbjPriNum){
        //3.1、定义PrisonerMain
        PrisonerMain prisonerMain = new PrisonerMain();
        //3.2、取出map中prisonerMain属性
        String pName = (String)mainMaps.get("p_name");
        String usedName = (String)mainMaps.get("used_name");
        String sex = (String)mainMaps.get("sex");
        //之前对接黑龙江未按照安置帮教传递，做过处理(可以去掉)
        String nationality = (String)mainMaps.get("nationality");
        if(null != nationality && 1 == nationality.length()) {
            nationality = "0" + nationality;
        }
        String idType = (String)mainMaps.get("idType");
        String idNum = (String)mainMaps.get("id_num");
        Date age = (Date)mainMaps.get("age");
        String education = (String)mainMaps.get("education");
        Date addTime = (Date)mainMaps.get("addtime");
        String priAddr = (String)mainMaps.get("pri_addr");
        //户籍地
        String nativePro = (String)mainMaps.get("nativepro");
        String nativeCity = (String)mainMaps.get("nativecity");
        String nativeCou = (String)mainMaps.get("nativecou");
        String nativeVill = (String)mainMaps.get("nativevill");
        //之前黑龙江nativevill传递中文，做过处理(可以去掉)
        if(!StringUtils.isEmpty(nativeVill) && !PATTERN.matcher(nativeVill).matches()) {
            nativeVill = "";
        }
        String nativeNum = (String)mainMaps.get("nativenum");
        //居住地
        String placePro = (String)mainMaps.get("placepro");
        String placeCity = (String)mainMaps.get("placecity");
        String placeCou = (String)mainMaps.get("placecou");
        String placeVill = (String)mainMaps.get("placevill");
        if(!StringUtils.isEmpty(placeVill) && !PATTERN.matcher(placeVill).matches()) {
            placeVill = "";
        }
        String placeNum = (String)mainMaps.get("placenum");
        //逮捕机构
        String arrestPro = (String)mainMaps.get("arrestpro");
        String arrestCity = (String)mainMaps.get("arrestcity");
        String arrestCou = (String)mainMaps.get("arrestcou");
        String arrestVill = (String)mainMaps.get("arrestvill");
        if(!StringUtils.isEmpty(arrestVill) && !PATTERN.matcher(arrestVill).matches()) {
            arrestVill = "";
        }
        String arrestNum = (String)mainMaps.get("arrestnum");
        //原侦查机关
        String investigatePro = (String)mainMaps.get("investigate_pro");
        String investigateCity = (String)mainMaps.get("investigate_city");
        String investigateCou = (String)mainMaps.get("investigate_cou");
        String investigateVill = (String)mainMaps.get("investigate_vill");
        if(!StringUtils.isEmpty(investigateVill) && !PATTERN.matcher(investigateVill).matches()) {
            investigateVill = "";
        }
        String investigateNum = (String)mainMaps.get("investigate_num");

        //3.3、封装实体类prisonerMain
        prisonerMain.setPriNum(azbjPriNum);
        prisonerMain.setPName(pName);
        prisonerMain.setUsedName(usedName);
        prisonerMain.setSex(sex);
        prisonerMain.setNationality(nationality);
        prisonerMain.setIdType(idType);
        prisonerMain.setIdNum(idNum);
        prisonerMain.setAge(age);
        prisonerMain.setEducation(education);
        prisonerMain.setAddtime(addTime);
        prisonerMain.setPriAddr(priAddr);
        prisonerMain.setNativepro(nativePro);
        prisonerMain.setNativecity(nativeCity);
        prisonerMain.setNativecou(nativeCou);
        prisonerMain.setNativevill(nativeVill);
        prisonerMain.setNativenum(nativeNum);
        prisonerMain.setPlacepro(placePro);
        prisonerMain.setPlacecity(placeCity);
        prisonerMain.setPlacecou(placeCou);
        prisonerMain.setPlacevill(placeVill);
        prisonerMain.setPlacenum(placeNum);
        prisonerMain.setArrestpro(arrestPro);
        prisonerMain.setArrestcity(arrestCity);
        prisonerMain.setArrestcou(arrestCou);
        prisonerMain.setArrestvill(arrestVill);
        prisonerMain.setArrestnum(arrestNum);
        prisonerMain.setInvestigatePro(investigatePro);
        prisonerMain.setInvestigateCity(investigateCity);
        prisonerMain.setInvestigateCou(investigateCou);
        prisonerMain.setInvestigateVill(investigateVill);
        prisonerMain.setInvestigateNum(investigateNum);
        prisonerMain.setCreateUser(account);
        prisonerMain.setUpdateUser(account);
        prisonerMain.setCreateTime(date);
        prisonerMain.setUpdateTime(date);
        return prisonerMain;
    }

    /**
     * 获取服刑信息
     * @param fxLists 中间库查询-服刑信息属性集合
     * @param date 创建与更新时间
     * @param account 用户账号
     * @return 服刑信息
     */
    private PrisonerFx getPrisonerFx(List<Map<String,Object>> fxLists,Date date,String account){
        PrisonerFx prisonerFx=null;
        for(int j = 0; j < fxLists.size(); j++) {
            prisonerFx = new PrisonerFx();
            //3.5.1 取出map中prisonerFx属性
            Map<String,Object> fxMaps = fxLists.get(j);
            checkTransform(fxMaps);
            String critype = (String)fxMaps.get("Critype");
            String precri = (String)fxMaps.get("Precri");
            String addpenalty = (String)fxMaps.get("Addpenalty");
            String jinengtype = (String)fxMaps.get("jinengtype");
            String pritime = (String)fxMaps.get("Pritime");
            String arrjg = (String)fxMaps.get("arr_jg");
            Date pribegin = (Date)fxMaps.get("Pri_begin");
            Date pristop = (Date)fxMaps.get("Pri_stop");
            String aftype = (String)fxMaps.get("Aftype");
            String bqzy = (String)fxMaps.get("bqzy");
            String fzlx = (String)fxMaps.get("fzlx");
            String canji = (String)fxMaps.get("canji");
            //3.5.2 封装实体类prisonerFx
            prisonerFx.setCritype(critype);
            prisonerFx.setPrecri(precri);
            prisonerFx.setAddpenalty(addpenalty);
            prisonerFx.setJinengtype(jinengtype);
            prisonerFx.setPritime(pritime);
            prisonerFx.setArrJg(arrjg);
            prisonerFx.setPriBegin(pribegin);
            prisonerFx.setPriStop(pristop);
            prisonerFx.setAftype(aftype);
            prisonerFx.setBqzy(bqzy);
            prisonerFx.setCanji(canji);
            prisonerFx.setUpdateUser(account);
            prisonerFx.setUpdateTime(date);
            //3.5.3 处理犯罪类型
            if(!StringUtils.isEmpty(critype) && StringUtils.isEmpty(fzlx)) {
                String[] critypes = critype.split(",");
                Set<String> fxSets = new HashSet<>(16);
                for(String c : critypes) {
                    //根据罪名查询对应的犯罪类型
                    String fzlxTemp = (String)stringRedisTemplate.opsForHash().get("critypeAndFzlx",c);
                    if(StringUtils.isBlank(fzlxTemp)) {
                        fzlxTemp = c;
                    }
                    fxSets.add(fzlxTemp);
                }
                String temp = "";
                for(String f : fxSets) {
                    if(!StringUtils.isEmpty(temp)) {
                        temp = new StringBuilder(16).append(temp).append(",").append(f).toString();
                    } else {
                        temp = f;
                    }
                }
                fzlx = temp;
            }
            prisonerFx.setFzlx(fzlx);
        }
        return prisonerFx;
    }

    /**
     * 获取社会关系信息集合
     * @param srLists 中间库-查询的社会关系信息
     * @param date 创建与更新时间
     * @param account 用户账号
     * @return 社会关系信息集合
     */
    private List<PrisonerSr> getPrisonerSrs(List<Map<String,Object>> srLists,Date date,String account){
        //3.7、处理PrisonerSr
        List<PrisonerSr> prisonerSrs = new ArrayList<>(16);
        for(Map<String,Object> srMaps : srLists) {
            PrisonerSr prisonerSr = new PrisonerSr();
            checkTransform(srMaps);
            String theName = (String)srMaps.get("thename");
            String relation = (String)srMaps.get("relation");
            //TODO 证件类型
            String idType = (String)srMaps.get("idtype");
            String idNumber = (String)srMaps.get("idnumber");
            String gender = (String)srMaps.get("sex");
            Date   age = (Date)srMaps.get("age");
            String danWei = (String)srMaps.get("danwei");
            String tel = (String)srMaps.get("tel");
            String mobile = (String)srMaps.get("mobile");
            String addrPro = (String)srMaps.get("addrpro");
            String addrCity = (String)srMaps.get("addrcity");
            String addrCou = (String)srMaps.get("addrcou");
            String addrVil = (String)srMaps.get("addrvil");
            if(!StringUtils.isEmpty(addrVil) && !PATTERN.matcher(addrVil).matches()) {
                addrVil = "";
            }
            String addrdeTail = (String)srMaps.get("addrdetail");

            //针对黑龙江约定做特殊处理
            if("000000000000000".equals(idNumber)) {
                idNumber = "";
            }
            //3.7.2 封装实体类PrisonerSr
            prisonerSr.setThename(theName);
            prisonerSr.setIdType(idType);
            prisonerSr.setRelation(relation);
            prisonerSr.setIdnumber(idNumber);
            prisonerSr.setGender(gender);
            prisonerSr.setAge(age);
            prisonerSr.setDanwei(danWei);
            prisonerSr.setTel(!StringUtils.isEmpty(tel) && "无".equals(tel) ? "" : tel);
            prisonerSr.setMobile(!StringUtils.isEmpty(mobile) && "无".equals(mobile) ? "" : mobile);
            prisonerSr.setAddrpro(addrPro);
            prisonerSr.setAddrcity(addrCity);
            prisonerSr.setAddrcou(addrCou);
            prisonerSr.setAddrvil(addrVil);
            prisonerSr.setAddrdetail(addrdeTail);
            prisonerSr.setCreateUser(account);
            prisonerSr.setUpdateUser(account);
            prisonerSr.setUpdateTime(date);
            prisonerSr.setCreateTime(date);
            prisonerSrs.add(prisonerSr);
        }
        return prisonerSrs;
    }

    /**
     * 获取未成年子女关系信息集合
     * @param znLists 中间库-查询的未成年子女关系信息
     * @param date 创建与更新时间
     * @param account 用户账号
     * @return 未成年子女关系信息集合
     */
    private List<PrisonerZn> getPrisonerZns(List<Map<String,Object>> znLists,Date date,String account){
        //3.9、处理prisonerZn
        List<PrisonerZn> prisonerZns = new ArrayList<>(16);
        for(Map<String,Object> znList : znLists) {
            checkTransform(znList);
            PrisonerZn prisonerZn = new PrisonerZn();
            //3.9.1 取出map中prisonerZn属性
            String name = (String)znList.get("name");
            String sex = (String)znList.get("sex");
            Date age = (Date)znList.get("age");
            String jianHuRen = (String)znList.get("jianhuren");
            String kunNan = (String)znList.get("kunnan");
            String shiXue = (String)znList.get("shixue");
            String liuLang = (String)znList.get("liulang");
            String fanZui = (String)znList.get("fanzui");
            String sfId = (String)znList.get("znsf_id");
            String nativePro = (String)znList.get("nativepro");
            String nativeCity = (String)znList.get("nativecity");
            String nativeCou = (String)znList.get("nativecou");
            String nativeVill = (String)znList.get("nativevill");
            if(!StringUtils.isEmpty(nativeVill) && !PATTERN.matcher(nativeVill).matches()) {
                nativeVill = "";
            }
            String nativeNum = (String)znList.get("nativenum");

            String placePro = (String)znList.get("placepro");
            String placeCity = (String)znList.get("placecity");
            String placeCou = (String)znList.get("placecou");
            String placeVill = (String)znList.get("placevill");
            if(!StringUtils.isEmpty(placeVill) && !PATTERN.matcher(placeVill).matches()) {
                placeVill = "";
            }
            String placeNum = (String)znList.get("placenum");
            //3.9.2 封装实体类prisonerZn
            prisonerZn.setName(name);
            //默认写死身份证号。
            prisonerZn.setIdType(Constants.NumberStr.NUM_STR_ONE);
            prisonerZn.setSex(sex);
            prisonerZn.setAge(age);
            prisonerZn.setJianhuren(jianHuRen);
            prisonerZn.setKunnan(kunNan);
            prisonerZn.setShixue(shiXue);
            prisonerZn.setLiulang(liuLang);
            prisonerZn.setFanzui(fanZui);
            prisonerZn.setZnsfId(sfId);
            prisonerZn.setNativepro(nativePro);
            prisonerZn.setNativecity(nativeCity);
            prisonerZn.setNativecou(nativeCou);
            prisonerZn.setNativevill(nativeVill);
            prisonerZn.setNativenum(nativeNum);
            prisonerZn.setPlacepro(placePro);
            prisonerZn.setPlacecity(placeCity);
            prisonerZn.setPlacecou(placeCou);
            prisonerZn.setPlacevill(placeVill);
            prisonerZn.setPlacenum(placeNum);
            prisonerZn.setCreateUser(account);
            prisonerZn.setUpdateUser(account);
            prisonerZn.setUpdateTime(date);
            prisonerZn.setCreateTime(date);
            //3.9.3 添加prisonerZn到list
            prisonerZns.add(prisonerZn);
        }
        return prisonerZns;
    }

    /**
     * 获取头像，指纹等信息
     * @param mediaLists 从中间库中查询-多媒体信息
     * @return List<MultimediaInfo>
     */
    private List<MultimediaInfo> getMultimediaInfo(List<Map<String,Object>> mediaLists) {
        List<MultimediaInfo> multimediaInfos = new ArrayList<>(16);
        for(Map<String,Object> mediaList : mediaLists) {
            MultimediaInfo multimediaInfo = new MultimediaInfo();
            //3.11.1 取出map中multimediaInfo属性
            Map<String,Object> mediaMaps = mediaList;
            checkTransform(mediaMaps);
            String imgId = (String)mediaMaps.get("IMG_TASK_ID");
            String zwsId = (String)mediaMaps.get("ZW_TASK_ID");
            String priNum = (String)mediaMaps.get("PRI_NUM");
            //3.11.2 封装实体类multimediaInfo
            multimediaInfo.setImgId(imgId);
            multimediaInfo.setZwId(zwsId);
            multimediaInfo.setPriNumGd(priNum);
            //3.11.3 添加multimediaInfo到list
            multimediaInfos.add(multimediaInfo);
        }
        return multimediaInfos;
    }
}